<?php
class Foxsis_Form_Cliente extends Zend_Form
{
    public function init()
    {
    	$view = $this->getView();
        $this->setAction($view->url(array('controller' => 'cliente', 'action' => 'save'), 'default', 'true'));
        $this->setMethod('POST');

        $this->setName("Cliente");
		
        $id_cliente = new Zend_Form_Element_Hidden('id_cliente');
        $id_cliente->addFilter('Int');
        
        $id_usuario = new Zend_Form_Element_Hidden('id_usuario');
        $id_usuario->addFilter('Int')
                   ->setValue(Zend_Auth::getInstance()->getIdentity()->id_usuario);
        
        $nome = new Zend_Form_Element_Text('nome');
        $nome->setLabel('Nome:')
                 ->setRequired(true)
                 ->addFilters(array('StripTags','StringTrim'))
                 ->addValidator('NotEmpty')
                 ->setAttrib("size", "50");


        $email = new Zend_Form_Element_Text('email');
        $email->setLabel('Email:')
                 ->setRequired(true)
                 ->addFilters(array('StripTags','StringTrim'))
                 ->addValidators(array('NotEmpty','EmailAddress'))
                 ->setAttrib("size", "50");

        $telefone = new Zend_Form_Element_Text('telefone');
        $telefone->setLabel('Telefone:')
                 ->setRequired(true)
                 ->addFilters(array('StripTags','StringTrim'))
                 ->addValidator('NotEmpty')
                 ->setAttrib("size", "20");

        $status = new Zend_Form_Element_Select('ativo');
        $status->setLabel('Status:')
               ->setRequired(true)
               ->addValidator('NotEmpty')
               ->setMultiOptions(array(""=>"-- Selecione --","1"=>"Ativo","0"=>"Inativo"));
        
        /*$plano = new Plano();
        $result = $plano->fetchAll();
               
        $id_plano = new Zend_Form_Element_Select('id_plano');
        $id_plano->setLabel('Plano:')
        		 ->setRequired(true)
                 ->addValidator('NotEmpty')
                 ->addMultiOption("", "-- Selecione --");
                 
    	foreach ($result as $plano) {
			$id_plano->addMultiOption($plano->id_plano, $plano->nome);
		}*/
                 
        
        $this->addElements(
            array($nome, $email, $telefone, $status, $id_cliente, $id_usuario)
        );
    }
}